<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue-2.6.12.js"></script>
</head>
<body>
  <div id="app">
    <mytable></mytable>
  </div>
  <template id="table-head">
    <thead>
      <tr>
        <td>编号</td>
        <td>商品名</td>
        <td>价格</td>
      </tr>
    </thead>
  </template>
  <template id="table-body">
    <thead>
      <tr v-for="(item,index) in test" :key="index">
        <td>{{item.id}}</td>
        <td>{{item.name}}</td>
        <td>{{item.price}}</td>
      </tr>
    </thead>
  </template>
  <template id="mytable">
    <table border="1" align="center">
      <thead is="table-head"></thead>
      <tbody is="table-body" :test="products"></tbody>
    </table>
  </template>
  <script>
    
    var tableHead = {
      template:"#table-head"
    };
    var tableBody = {
      template:"#table-body",
      props:["test"]
    };
    var mytable = {
      template:"#mytable",
      components:{
        tableHead,
        tableBody
      },
      data:function(){
        return {
          products:[{id:1,name:"su7",price:21},{id:2,name:"byd",price:21}]
        }
      }
    };
    new Vue({
      el:"#app",
      components:{
        mytable
      }
    });
  </script>
</body>
</html>